package com.nunbey.lingxi.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.nunbey.lingxi.mode.record.RecordDTO;
import com.nunbey.lingxi.service.RecordService;
import common.webresult.WebResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;


/**
 * @author lincat
 */
@Tag(name = "ECG", description = "ECG模块接口")
@RequestMapping("/ECG")
@RestController
@CrossOrigin
public class RecordController {
    @Autowired
    private RecordService recordService;

    /**
     * 记录ECG监护数据，并判别，最后将数据返回
     * @param recordEntity
     * @return
     */
    @PostMapping("/recordAndDistinguish")
    @Operation(summary = "记录ECG监护数据，并判别，最后将数据返回")
    @SaCheckLogin
    public WebResult recordAndDistinguish(@RequestBody RecordDTO recordEntity,@RequestHeader("token") String token) throws IOException {
        return recordService.recordAndDistinguish(recordEntity);
    }

    /**
     * 根据ECG记录ID获取ECG记录
     * @param recordId
     * @return
     */
    @PostMapping("/getRecordByRecordId")
    @Operation(summary = "根据ECG记录ID获取ECG记录")
    @SaCheckLogin
    public WebResult getRecordByRecordId(@RequestBody Long recordId,@RequestHeader("token") String token){
        return recordService.getRecordByRecordId(recordId);
    }

    /**
     * 获取某个用户的ECG记录列表
     * @return
     */
    @GetMapping("/getRecordList")
    @Operation(summary = "获取某个用户的ECG记录列表")
    @SaCheckLogin
    public WebResult getUserRecordList(@RequestHeader("token") String token){
        return recordService.getUserRecordList();
    }


}
